package fit.deni.hibernate;

import java.util.Collection;

import org.apache.tapestry5.hibernate.annotations.CommitAfter;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

import fit.deni.beans.Telefon;
import fit.deni.hibernate.interfaces.TelefonService;

public class TelefonServiceImpl implements TelefonService {

	private Session session;

	public TelefonServiceImpl(Session session) {
		this.session = session;
	}
	
	@CommitAfter
	public void addPhone(Telefon t) {
		session.merge(t);
	}
	
	public Collection<Telefon> getAll() {
		return session.createCriteria(Telefon.class).add(Restrictions.eq("deleted", false)).list();
	}

}
